<?php

namespace Common\Logic;

/**
 * Description of 酒店申请开通业务逻辑层
 * 
 * @author zhangzhen
 * @date 2017-01-03
 */
class DealerApplyLogic extends \Common\Controller\BaseController {

    /**
     * 用户提交客栈申请
     * @modify zhangzhen 2017-01-03 
     * @modify wenhui 2017-05-22 添加区号
     * @param string $mobile
     * @param string $name
     * @param string $idcard
     * @param string $idcardpath
     * @param string $remark
     * @param string $areaCode
     */
    public function apply($mobile, $name, $idcard, $idcardpath, $remark = null, $areaCode = '86') {
        //检查手机号是否已
        $dealerApplyModel = D('DealerApply');
        $dealerApply = $dealerApplyModel->getInfoByMobile($mobile, $areaCode);
        if ($dealerApply) {
            returnJson(403, 104);
        }
        $result = $dealerApplyModel->addInfo($mobile, $name, $idcard, $idcardpath, null, $areaCode);
        if (!$result) {
            returnJson(500, 508);
        }
        //发送邮件通知
        $email = new \Org\Util\Email();

        foreach (C('SIGNIN_NOTIFICATION_EMAIL') as $emailToSend) {
            $email->applyDealer($emailToSend, $name, $mobile);
        }
        unset($emailToSend);
    }
}
